package entity

import "time"
/**
* @title 任务类
 */
type Task struct {
	Id        int64  `json:"id"orm:"pk;auto"`
	ProductId int64 `json:"productId" form:"productId" orm:"null"`
	UserId 	  int64 `json:"userId" orm:"null"`
	Title     string `json:"title" form:"title"`
	Status    int32 `json:"status"`
	Group     string `json:"group"`
	Uri       string `json:"uri" form:"uri"`
	Param 	  *Param `json:"param" orm:"rel(one)"`
	Result 	  *Result `json:"result" orm:"rel(one)"`
	CreateTime time.Time `json:"createTime" orm:"auto_now_add;type(datetime)"`
	UpdateTime time.Time `json:"updateTime" orm:"auto_now;type(datetime)"`
	DeleteTime *time.Time `json:"deleteTime" orm:"null"`
}

// 多字段索引
func (m *Task) TableIndex() [][]string {
	return [][]string{
		[]string{"UserId"},
	}
}

// 多字段唯一键
func (m *Task) TableUnique() [][]string {
	return [][]string{
		[]string{"Id", "ProductId"},
	}
}


func (m *Task) TableName() string {
	return "task"
}

// 设置引擎为 INNODB
func (m *Task) TableEngine() string {
	return "INNODB"
}



/**
* @title 任务参数
 */
type Param struct {
	Id         int64 `json:"id"orm:"pk;auto"`
	TaskId	   int64 `json:"taskId"`
	Title      string `json:"title"`
	Method     string `json:"method"`
	template   string `json:"template"`
	CreateTime time.Time `json:"createTime" orm:"auto_now_add;type(datetime)"`
	UpdateTime time.Time `json:"updateTime" orm:"auto_now;type(datetime)"`
	DeleteTime *time.Time `json:"deleteTime" orm:"null"`
}

func (m *Param) TableName() string {
	return "param"
}
/**
* @title 任务结果
 */
type Result struct {
	Id      int64 `json:"id"orm:"pk;auto"`
	TaskId   int64 `json:"taskId"`
	Result    string `json:"result"`
	CreateTime time.Time `json:"createTime" orm:"auto_now_add;type(datetime)"`
	UpdateTime time.Time `json:"updateTime" orm:"auto_now;type(datetime)"`
	DeleteTime *time.Time `json:"deleteTime" orm:"null"`
}

func (m *Result) TableName() string {
	return "result"
}